using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ShareTools.GroupsService;

namespace ShareTools.GroupsManager
{
    public partial class GroupsManager : Form
    {
        public GroupsManager()
        {
            InitializeComponent();
        }

        private void btnDeleteGroups_Click(object sender, EventArgs e)
        {
            GroupsServiceManager gpServMgr = new GroupsServiceManager();
            gpServMgr.DomainName = txtDomainName.Text;
            gpServMgr.UserName = txtUserName.Text;
            gpServMgr.Password = txtPassword.Text;
            gpServMgr.WebServiceURI = txtSiteURL.Text + (txtSiteURL.Text.EndsWith("/") ? "_vti_bin/usergroup.asmx" : "/_vti_bin/usergroup.asmx");
                //http://dev.ap.ctc.seic.com/_vti_bin/usergroup.asmx
            if (!string.IsNullOrEmpty(txtExclusions.Text.Trim()))
            {
                string[] exclusions = txtExclusions.Text.Split(new char[] { ',' });
                if (exclusions.Length > 0)
                {
                    List<string> exclList = new List<string>(exclusions);
                    gpServMgr.GroupExclusions = exclList;
                }
            }
            string output = gpServMgr.DeleteGroups();
            richTxtOutput.Text = output;
        }

        private void btnListGroups_Click(object sender, EventArgs e)
        {
            GroupsServiceManager gpServMgr = new GroupsServiceManager();
            gpServMgr.DomainName = txtDomainName.Text;
            gpServMgr.UserName = txtUserName.Text;
            gpServMgr.Password = txtPassword.Text;
            gpServMgr.WebServiceURI = txtSiteURL.Text + (txtSiteURL.Text.EndsWith("/") ? "_vti_bin/usergroup.asmx" : "/_vti_bin/usergroup.asmx");
            //http://dev.ap.ctc.seic.com/_vti_bin/usergroup.asmx
            string output = gpServMgr.DeleteGroups();
            richTxtOutput.Text = output;
        }
    }
}